package br.com.threads;


class CBC implements Runnable{
	public void run(){
		int total = 0;
		for(int i = 1; i <= 5; i++){
			total += i;
			System.out.println("Total: " + total+ " " + Thread.currentThread().getName()+ " ");
			}
		}
}
public class Programa39{
	public static void main(String[] args) {
		CBC c = new CBC();
		Thread t1 = new Thread(c);
		Thread t2 = new Thread(c);	
		t1.setName("Thread 1");
		t2.setName("Thread 2");
		t1.start();
		t2.start();
		try{
			t1.join();//Thread 2 so deve ser executada quando a Thread 2 finalizar.
		}catch(InterruptedException e){e.printStackTrace();}
		
		
		
	}
}
